The following sections describe the geometric properties of style objects, which you can use to apply certain types of stylistic variations to QuickDraw GX shapes. In particular, they show how you can
A style is a group of stylistic variations applied to a shape. QuickDraw GX provides two major categories of stylistic variations: geometric variations, which include pen width, dashes, patterns, and so on, and typographic variations, which include font, font size, type style, and so on.
Both types of stylistic variation are encapsulated in a style object. Like a shape object, a style object is a data structure. Each style object has a group of properties, and each style property represents a different stylistic variation.
In general, a shape object is an object with a group of properties that describe a geometry; a style object is an object with a group of properties that affect how QuickDraw GX interprets a shape's geometry during drawing.
Every QuickDraw GX shape object contains a reference to a style object. As Figure 18 depicts, a single style object can be shared by multiple shape objects.
Figure 18 Shared style objects
As with all objects, a style object has an owner count, which reflects the number of existing references to the style object. When a new reference to a style object is created, the owner count of the style object is incremented; when a reference to a style object goes away, the owner count of the style object is decremented. When a style object has an owner count of 0, QuickDraw GX can free the memory used by the style object.
References to style objects typically include those contained in shape objects and those contained in variables in your application. QuickDraw GX manages the owner counts corresponding to references in shape objects for you; you are responsible for managing the owner counts corresponding to variables in your application.
A style object contains properties that the drawing of a shape. The style properties that affect paths are:
The contours of framed paths are drawn with the QuickDraw GX geometric pen. You can specify the width of this pen using the pen width property of the style object, and you can specify where to place the pen relative to the contours of a shape using the style attributes, which are described in "Style Attributes," .
Conceptually, the QuickDraw GX geometric pen is a line that QuickDraw GX drags along the contours of the shape being drawn--always keeping it perpendicular to the contours. In effect, the geometric pen turns a framed geometry into a filled one. For example, a line shape, which is always framed, becomes the equivalent of a filled polygon after QuickDraw GX applies the geometric pen.
Figure 19 shows the effect of the geometric pen. This figure shows two geometries-- a line geometry and a curve geometry--and how QuickDraw GX draws them with a pen width of 15.
Figure 19 The QuickDraw GX geometric pen
Notice that the ends of the thick line contour and the thick curve contour in Figure 19 are perpendicular to the direction of the contours themselves.
Figure 20 shows the effect of different pen widths on a semicircular path shape.
Figure 20 Differing pen widths
The style attributes property of a style object contains six attributes that affect the drawing of a shape. Four of these attributes affect how QuickDraw GX places the geometric pen relative to the contours of a shape:
These four attributes are discussed in the next section, "Pen Placement."
There are also two style attributes that determine whether the geometric points of a shape are constrained to a grid when the shape is drawn:
You can use the center-frame, inside-frame, and outside-frame style attributes to specify where QuickDraw GX should position the pen with respect to the shape's geometry.
Figure 21 shows the results of these style attributes. Notice that QuickDraw GX considers contour direction when determining which side of a contour is the inside: the right side of the contour is the inside, while the left side of the contour is the outside.
QuickDraw GX also provides the auto-inset style attribute, which allows you to specify that QuickDraw GX should ignore contour direction when determining which side of a contour is the inside. When you set this style attribute, QuickDraw GX determines the true inside of a contour, rather than using the right side as the inside. Figure 22 shows the effect of setting the auto-inset style attribute for the shapes depicted in Figure 21 .
Figure 22 Effect of the auto-inset style attribute
When a contour crosses over itself, the results of setting the auto-inset style attribute are unpredictable, as the contour has no true inside (or, actually, has multiple true insides). For the figure-eight shape in Figure 23 , setting the gxAutoInsetStyle and the gxInsideFrameStyle style attributes could lead to one of two results.
Figure 23 Effect of the auto-inset and inside-frame style attributes for a crossed contour
QuickDraw GX uses the join property of a shape's style object to store information about the joins of a shape.
You can use the join attributes to specify two types of standard joins--sharp joins and curve joins, as shown in Figure 24 .
For sharp joins, QuickDraw GX allows you to specify a miter --the maximum distance between the actual corner of a shape's geometry and the corner as drawn, as shown in Figure 25 .
Figure 25 Sharp join with miter
An ink object describes a shape's color and its transfer mode--how that color is applied when the shape is drawn. Inks support many different kinds of color specification, and many different transfer modes.
This section explains the use of transfer modes in drawing shapes. It also introduces QuickDraw GX ink objects and describes their properties. Finally, it describes how transfer modes work in QuickDraw GX.
An ink object exists to provide color information about a shape. Each QuickDraw GX shape consists of a shape object, a style object, an ink object, and a transform object; the ink object associated with a shape defines the color with which the shape is drawn, as well as the transfer mode used to draw it.
Inks are device independent. Their information is not affected by the properties of the display device to which the shapes they modify are drawn. When it draws a shape on a device, QuickDraw GX approximates as closely as possible the color specified by the shape's ink.
For QuickTime vectors, there is one accessible property in an ink object:
The transfer mode also includes a specification of a color space.
One main purpose of an ink object's existence is to specify the color of a shape. Because there is only one ink object per shape, it follows that each QuickDraw GX shape can have only one color. The only exception to this is for bitmap shapes, which use pixel values rather than an ink object to specify colors. (Picture shapes have no color at all apart from the colors of their component shapes, and thus do not use their ink object.)
The color in an ink object is defined with a gxColor structure:
struct gxColor{
gxColorSpace space;
gxColorProfile profile;
union {
struct gxCMYKColor cmyk;
struct gxRGBColor rgb;
struct gxRGBAColor rgba;
struct gxHSVColor hsv;
struct gxHLSColor hls;
struct gxXYZColor xyz;
struct gxYXYColor yxy;
struct gxLUVColor luv;
struct gxLABColor lab;
struct gxYIQColor yiq;
gxColorValue gray;
struct gxGrayAColor graya;
unsigned short pixel16;
unsigned long pixel32;
struct gxIndexedColor indexed;
gxColorValue component[4];
} element;
};
The color structure specifies three characteristics of a color:
The transfer mode in an ink object is contained in a gxTransferMode structure:
struct gxTransferMode{
gxColorSpace space;
gxColorSet set;
gxColorProfile profile;
Fixed sourceMatrix[5][4];
Fixed deviceMatrix[5][4];
Fixed resultMatrix[5][4];
gxTransferFlag flags;
struct gxTransferComponent component[4];
};
Like the color structure just described, the transfer mode structure specifies a color space. A transfer mode specifies its own color space because it can perform its operations according to its own definitions of color, independent of the color specifications in the rest of the ink object.
The transfer mode structure contains three 5 4 matrices (5 rows, 4 columns), the source matrix, device matrix, and result matrix, which it can use to transform colors for special effects, by blending proportions of the colors' components. In addition, it contains a set of transfer mode flags that control several aspects of the transfer mode operation.
The structure also contains up to four transfer components, used along with the matrices in the transfer mode operation. Transfer components contain the actual specification of the mode of transfer to use when drawing. Transfer components are defined by the gxTransferComponent structure:
struct gxTransferComponent{
gxComponentMode mode;
gxComponentFlag flags;
gxColorValue sourceMinimum;
gxColorValue sourceMaximum;
gxColorValue deviceMinimum;
gxColorValue deviceMaximum;
gxColorValue clampMinimum;
gxColorValue clampMaximum;
gxColorValue operand;
};
A transfer component contains a component mode specifying the type of transfer mode (like "copy" or "XOR") to use, an operand to apply (if the type calls for an operand), a set of maximum and minimum color values, and a set of flags. There is one transfer component for each color component (dimension) in the transfer mode's color space. Each of the transfer components in the transfer mode structure may specify a different component mode, which means that each dimension of a color space can be drawn with a different transfer mode when a shape is drawn.
How these parts of the transfer mode structure and transfer component structure define the transfer mode for drawing, and how you can use transfer modes to obtain the proper effect when drawing, are described in the section "Transfer Modes," .